<?php
/**
 * Source code under Creative Commons License 
 * (see LICENSE FILE)
*
 *
 * @author      Maelstrom <devcreamframework@gmail.com>
 * @link        https://github.com/maelstromkd/cream-dev.git
 * @version     1.2
 */

require realpath(dirname(__FILE__)) . '/../core/paths.php';
require __CORE__ . 'core.php';
    
    $_APP = new Backend();
    $_APP->setCache(false);

$path = 'users';
if($_GET['id'] != 1){
	$path = 'clients';
    $data = $_APP->_CRUD->read('name, firstname FROM clients 
    WHERE id=\'' . mysql_real_escape_string((int)$_GET['id']) . '\'');
    if($data){
        $user = $data;
        unset($data);
    }
}else{
    $user['firstname'] = 'Administrateur';
    $user['name'] = '';
}


$file = file('logs/' . $path . '/' . $_GET['id'] . '/' . $_GET['log']);
$output  = '<html><body style="background:#eee; font-family:verdana">';
$output .= '<h3>' . date('d/m/Y H:i:s', $_GET['log']) . ' - ' . $user['firstname'] . ' ' . $user['name'] . '</h3>';
foreach($file as $line){
    $output .= '<pre>' . $line . '</pre>';
}
$output .= '</body></html>';
echo $output;